package com.jgame.secondarymarket.domain.product.repository.db;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jgame.secondarymarket.domain.product.entity.ProductProperties;
import com.jgame.secondarymarket.domain.product.repository.ProductPropertiesRepository;
import com.jgame.secondarymarket.domain.product.repository.db.mapper.ProductPropertiesMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @title: ProductPropertiesRepositoryImpl
 * @Author Wangsj
 * @Date: 2021/7/22
 */
@Service
public class ProductPropertiesRepositoryImpl extends ServiceImpl<ProductPropertiesMapper, ProductProperties> implements ProductPropertiesRepository {

    @Override
    public void deletByProductId(Long productId) {
        this.remove(new LambdaQueryWrapper<ProductProperties>().eq(ProductProperties::getProductId, productId));
    }

    @Override
    public void deletByIds(Long productId, List<Long> propertiesId) {
        this.remove(new LambdaQueryWrapper<ProductProperties>()
                .eq(ProductProperties::getProductId, productId)
                .in(ProductProperties::getId, propertiesId));
    }

    @Override
    public List<ProductProperties> listByProductId(Long productId) {
        return this.list(new LambdaQueryWrapper<ProductProperties>().eq(ProductProperties::getProductId, productId));
    }

    @Override
    public List<ProductProperties> listByProductId(List<Long> productIds) {
        return this.list(new LambdaQueryWrapper<ProductProperties>().in(ProductProperties::getProductId, productIds));
    }
}
